package com.donquijote.dynamic.config;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 421527548@qq.com
 * @version V1.0
 * @title
 * @description
 * @date 2022-11-27 09:41
 */
public class TimerProxy implements InvocationHandler {
    Object target;

    public TimerProxy(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        long start = System.currentTimeMillis();
        Object invoke = method.invoke(target, args);
        long end = System.currentTimeMillis();
        System.out.println("用时：" + (end - start) + "毫秒");
        return invoke;
    }
}
